#!/bin/sh 
lftp_enfry()
{
cd /root/data
HOST=192.168.1.33
USER=root
PASS=enfry#2017
echo "Starting to sftp..."
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
cd /home/tomcat/data/release
mget e.war
bye
EOF
echo "done"
}

lftp_gateway()
{
cd /root/data
HOST=192.168.1.33
USER=root
PASS=enfry#2017
echo "Starting to sftp..."
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
cd /home/tomcat/data/release
mget g.war
bye
EOF
echo "done"
}


echo "首先=======================选择获取的WAR包========================================================================"
echo "请按照如下提示选择要获取的WAR包："
echo "0:表示enfry.war和gateway.war"
echo "1:表示enfry.war"
echo "2:表示gateway.war"
read -p "请输入本次要获取的WAR包:" tomcatNum
if [ ! $tomcatNum ]; then 
echo "输入错误，请重新执行"
else
	if [ $tomcatNum  -eq 1 ]; then
	echo "当前输入的获取的WAR包为：enfry.war"
	lftp_enfry
	elif [ $tomcatNum  -eq 2 ]; then
	echo "当前输入的获取的WAR包为：gateway.war"
	lftp_gateway
	elif [ $tomcatNum  -eq 0 ]; then
	echo "当前输入的获取的WAR包为：enfry.war和gateway.war"
	lftp_enfry
	lftp_gateway
	else
	echo "用户选择错误，请重新执行===================="
	fi
fi
